// api/routes/auth_routes.go
// api/routes/auth_routes.go
package routes

import (
	"mygin/api/handlers"
	"mygin/config"
	"mygin/internal/repositories"
	"mygin/internal/services"

	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

func RegisterAuthRoutes(r *gin.RouterGroup, db *gorm.DB) {
	// 初始化所有依赖
	jwtCfg := config.LoadJWTConfig()                         // 假设你有这个配置加载方法
	authRepo := repositories.NewAuthRepository(db)           // 使用AuthRepository
	authService := services.NewAuthService(jwtCfg, authRepo) // 类型匹配
	authHandler := handlers.NewAuthHandler(authService)

	authRoutes := r.Group("/auth")
	{
		authRoutes.POST("/login", authHandler.Login)
		authRoutes.POST("/register", authHandler.Register)
		authRoutes.POST("/refresh", authHandler.RefreshToken)
	}
}

func RegisterAuthRoutesV2(r *gin.RouterGroup, db *gorm.DB) {
	// authRepo := repositories.NewAuthRepository(db)
	// authService := services.NewAuthService(authRepo)
	// authHandler := handlers.NewAuthHandler(authService)

	// // 需要认证的路由组
	// secured := r.Group("/auth")
	// secured.Use(middleware.JWTAuthMiddleware(authService))
	// secured.Use(middleware.LoggerMiddleware()) // 可以添加其他中间件
	// {
	// 	//secured.GET("/profile", authHandler.GetProfile)
	// 	//secured.POST("/logout", authHandler.Logout)
	// }
}
